#ifndef ModeGame_h__
#define ModeGame_h__

#include <GTL.h>
#include <GTLEngine.h>

#include "Game.h"

template <typename T, typename U>
void EraseIfEqual(T& container, const U& val)
{
	for (size_t i=0; i<container.size(); i++)
	{
		if (container[i] == val)
		{
			delete container[i];
			container.erase(container.begin()+i);
			return;
		}
	}
}

struct Tile
{
	int Type;
};

struct Creature
{
	int Type;
	int X, Y;
	int Owner;
	int Race;
	int AP;
	int HP;
	int MP;
};

struct Map
{
	Tile Tiles[20][20];
	Point SpawnPoint[4];
	int MaxPlayers;
	eastl::vector<Creature*> Creatures;

	void RemoveCreature(const Creature* cr)
	{
		EraseIfEqual(Creatures, cr);
	}
};

class ModeGame : public GTL::Engine::GameMode<SummonerGame>
{
public:
	gui (gMain, "Data/gui/game.wilson");
	GTL::Engine::NetworkService* net;

	Map TheMap;

	virtual int Draw(float dt);
	virtual int Load();
	virtual int Event(GTL::Engine::GameEvent event);
	virtual int Unload();
	virtual int Update(float dt);
	void DoServerPacket( tn_packet* packet );
};

#endif // ModeGame_h__